import React from 'react';
import { Router, Route, Switch } from 'dva/router';
import IndexPage from './routes/IndexPage';
import dynamic from 'dva/dynamic'

function RouterConfig({ history, app }) {
  return (
    <Router history={history}>
      <Switch>
      <Route path="/" exact component={
          dynamic({
            app,
            component: ()=> import('./routes/login'),
            models: ()=> [import('./models/login')]
          })
        } />
        <Route path="/index" exact component={
          dynamic({
            app,
            component: ()=> import('./routes/IndexPage'),
            models: ()=> [import('./models/index')]
          })
        } />
        <Route path="/detail" exact component={
          dynamic({
            app,
            component: ()=> import('./routes/detail/index'),
            models: ()=> [import('./models/detail/index')]
          })
        } />
        <Route path="/contacts" exact component={
          dynamic({
            app,
            component: ()=> import('./routes/contacts/index'),
            models: ()=> [import('./models/contacts/index')]
          })
        } />
      </Switch>
    </Router>
  );
}

export default RouterConfig;
